Convert GailScrollbar to GtkScrollbarAccessible
authorMatthias Clasen <mclasen@redhat.com>
Mon, 27 Jun 2011 02:32:34 +0000 (22:32 -0400)
committerMatthias Clasen <mclasen@redhat.com>
Tue, 5 Jul 2011 20:08:53 +0000 (16:08 -0400)
gtk/a11y/Makefile.am
gtk/a11y/gail.c
gtk/a11y/gailscrollbar.c [deleted file]
gtk/a11y/gailscrollbar.h [deleted file]
gtk/a11y/gtkscrollbaraccessible.c [new file with mode: 0644]
gtk/a11y/gtkscrollbaraccessible.h [new file with mode: 0644]
gtk/gtkscrollbar.c
tests/a11y/appchooser.txt

index a41c16bad6bfe389a08223ceb2f37da8b1b240dd..630b18c8b807cd0fff4049725b37ba1f1c60640e 100644 (file)
@@ -38,7 +38,7 @@ gail_c_sources =                      \
        gailrenderercell.c              \
        gtkscaleaccessible.c            \
        gailscalebutton.c               \
-       gailscrollbar.c                 \
+       gtkscrollbaraccessible.c        \
        gailscrolledwindow.c            \
        gtkspinbuttonaccessible.c       \
        gailsubmenuitem.c               \
@@ -90,7 +90,7 @@ gail_private_h_sources =              \
        gailrenderercell.h              \
        gtkscaleaccessible.h            \
        gailscalebutton.h               \
-       gailscrollbar.h                 \
+       gtkscrollbaraccessible.h        \
        gailscrolledwindow.h            \
        gtkspinbuttonaccessible.h       \
        gailsubmenuitem.h               \
index 3160cf2a1550fb2da3a2baae93490e1f06a24dad..dec6ccd381a3355173a7df53df3020cf34779849 100644 (file)
@@ -46,7 +46,6 @@
 #include "gailrenderercell.h"
 #include "gailrange.h"
 #include "gailscalebutton.h"
-#include "gailscrollbar.h"
 #include "gailscrolledwindow.h"
 #include "gailstatusbar.h"
 #include "gailtextcell.h"
@@ -123,7 +122,6 @@ GAIL_IMPLEMENT_FACTORY (GAIL_TYPE_TREE_VIEW, GailTreeView, gail_tree_view, GTK_T
 GAIL_IMPLEMENT_FACTORY (GAIL_TYPE_RADIO_BUTTON, GailRadioButton, gail_radio_button, GTK_TYPE_RADIO_BUTTON)
 GAIL_IMPLEMENT_FACTORY (GAIL_TYPE_SCROLLED_WINDOW, GailScrolledWindow, gail_scrolled_window, GTK_TYPE_SCROLLED_WINDOW)
 GAIL_IMPLEMENT_FACTORY (GAIL_TYPE_PANED, GailPaned, gail_paned, GTK_TYPE_PANED)
-GAIL_IMPLEMENT_FACTORY (GAIL_TYPE_SCROLLBAR, GailScrollbar, gail_scrollbar, GTK_TYPE_SCROLLBAR)
 GAIL_IMPLEMENT_FACTORY_WITH_FUNC (GAIL_TYPE_CHECK_MENU_ITEM, GailCheckMenuItem, gail_check_menu_item, gail_check_menu_item_new)
 GAIL_IMPLEMENT_FACTORY_WITH_FUNC (GAIL_TYPE_RADIO_MENU_ITEM, GailRadioMenuItem, gail_radio_menu_item, gail_radio_menu_item_new)
 GAIL_IMPLEMENT_FACTORY (GAIL_TYPE_EXPANDER, GailExpander, gail_expander, GTK_TYPE_EXPANDER)
@@ -895,7 +893,6 @@ gail_accessibility_module_init (void)
   GAIL_WIDGET_SET_FACTORY (GTK_TYPE_RADIO_BUTTON, gail_radio_button);
   GAIL_WIDGET_SET_FACTORY (GTK_TYPE_SCROLLED_WINDOW, gail_scrolled_window);
   GAIL_WIDGET_SET_FACTORY (GTK_TYPE_PANED, gail_paned);
-  GAIL_WIDGET_SET_FACTORY (GTK_TYPE_SCROLLBAR, gail_scrollbar);
   GAIL_WIDGET_SET_FACTORY (GTK_TYPE_CHECK_MENU_ITEM, gail_check_menu_item);
   GAIL_WIDGET_SET_FACTORY (GTK_TYPE_RADIO_MENU_ITEM, gail_radio_menu_item);
   GAIL_WIDGET_SET_FACTORY (GTK_TYPE_EXPANDER, gail_expander);
diff --git a/gtk/a11y/gailscrollbar.c b/gtk/a11y/gailscrollbar.c
deleted file mode 100644 (file)
index 5d93c9a..0000000
+++ /dev/null
@@ -1,106 +0,0 @@
-/* GAIL - The GNOME Accessibility Implementation Library
- * Copyright 2001 Sun Microsystems Inc.
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the
- * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
- * Boston, MA 02111-1307, USA.
- */
-
-#include "config.h"
-
-#include <gtk/gtk.h>
-#include "gailscrollbar.h"
-
-static void gail_scrollbar_class_init  (GailScrollbarClass *klass);
-static void gail_scrollbar_init        (GailScrollbar      *accessible);
-static void gail_scrollbar_initialize  (AtkObject           *accessible,
-                                        gpointer             data);
-
-static gint gail_scrollbar_get_index_in_parent (AtkObject *accessible);
-
-G_DEFINE_TYPE (GailScrollbar, gail_scrollbar, GAIL_TYPE_RANGE)
-
-static void     
-gail_scrollbar_class_init (GailScrollbarClass *klass)
-{
-  AtkObjectClass *class = ATK_OBJECT_CLASS (klass);
-
-  class->initialize = gail_scrollbar_initialize;
-  class->get_index_in_parent = gail_scrollbar_get_index_in_parent;
-}
-
-static void
-gail_scrollbar_init (GailScrollbar      *accessible)
-{
-}
-
-static void
-gail_scrollbar_initialize (AtkObject *accessible,
-                           gpointer  data)
-{
-  ATK_OBJECT_CLASS (gail_scrollbar_parent_class)->initialize (accessible, data);
-
-  accessible->role = ATK_ROLE_SCROLL_BAR;
-}
-
-static gint
-gail_scrollbar_get_index_in_parent (AtkObject *accessible)
-{
-  GtkWidget *widget;
-  GtkWidget *parent;
-  GtkWidget *child;
-  GtkScrolledWindow *scrolled_window;
-  gint id;
-
-  widget = gtk_accessible_get_widget (GTK_ACCESSIBLE (accessible));
-
-  if (widget == NULL)
-  {
-    /*
-     * State is defunct
-     */
-    return -1;
-  }
-  g_return_val_if_fail (GTK_IS_SCROLLBAR (widget), -1);
-
-  parent = gtk_widget_get_parent (widget);
-  if (!GTK_IS_SCROLLED_WINDOW (parent))
-    return ATK_OBJECT_CLASS (gail_scrollbar_parent_class)->get_index_in_parent (accessible);
-
-  scrolled_window = GTK_SCROLLED_WINDOW (parent);
-  id = 0;
-  child = gtk_bin_get_child (GTK_BIN (scrolled_window));
-  if (child)
-    {
-      if (widget == child)
-        return id;
-      id++;
-    }
-
-  child = gtk_scrolled_window_get_hscrollbar (scrolled_window);
-  if (child)
-    {
-      if (widget == child)
-        return id;
-      id++;
-    }
-  child = gtk_scrolled_window_get_vscrollbar (scrolled_window);
-  if (child)
-    {
-      if (widget == child)
-        return id;
-    }
-
-  return -1;
-} 
diff --git a/gtk/a11y/gailscrollbar.h b/gtk/a11y/gailscrollbar.h
deleted file mode 100644 (file)
index 3b6b6fc..0000000
+++ /dev/null
@@ -1,51 +0,0 @@
-/* GAIL - The GNOME Accessibility Implementation Library
- * Copyright 2001 Sun Microsystems Inc.
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Library General Public
- * License as published by the Free Software Foundation; either
- * version 2 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.         See the GNU
- * Library General Public License for more details.
- *
- * You should have received a copy of the GNU Library General Public
- * License along with this library; if not, write to the
- * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
- * Boston, MA 02111-1307, USA.
- */
-
-#ifndef __GAIL_SCROLLBAR_H__
-#define __GAIL_SCROLLBAR_H__
-
-#include "gailrange.h"
-
-G_BEGIN_DECLS
-
-#define GAIL_TYPE_SCROLLBAR                     (gail_scrollbar_get_type ())
-#define GAIL_SCROLLBAR(obj)                     (G_TYPE_CHECK_INSTANCE_CAST ((obj), GAIL_TYPE_SCROLLBAR, GailScrollbar))
-#define GAIL_SCROLLBAR_CLASS(klass)             (G_TYPE_CHECK_CLASS_CAST ((klass), GAIL_TYPE_SCROLLBAR, GailScrollbarClass))
-#define GAIL_IS_SCROLLBAR(obj)                  (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GAIL_TYPE_SCROLLBAR))
-#define GAIL_IS_SCROLLBAR_CLASS(klass)          (G_TYPE_CHECK_CLASS_TYPE ((klass), GAIL_TYPE_SCROLLBAR))
-#define GAIL_SCROLLBAR_GET_CLASS(obj)           (G_TYPE_INSTANCE_GET_CLASS ((obj), GAIL_TYPE_SCROLLBAR, GailScrollbarClass))
-
-typedef struct _GailScrollbar          GailScrollbar;
-typedef struct _GailScrollbarClass     GailScrollbarClass;
-
-struct _GailScrollbar
-{
-  GailRange parent;
-};
-
-GType gail_scrollbar_get_type (void);
-
-struct _GailScrollbarClass
-{
-  GailRangeClass parent_class;
-};
-
-G_END_DECLS
-
-#endif /* __GAIL_SCROLLBAR_H__ */
diff --git a/gtk/a11y/gtkscrollbaraccessible.c b/gtk/a11y/gtkscrollbaraccessible.c
new file mode 100644 (file)
index 0000000..9193cd4
--- /dev/null
@@ -0,0 +1,93 @@
+/* GAIL - The GNOME Accessibility Implementation Library
+ * Copyright 2001 Sun Microsystems Inc.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the
+ * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
+ * Boston, MA 02111-1307, USA.
+ */
+
+#include "config.h"
+
+#include <gtk/gtk.h>
+#include "gtkscrollbaraccessible.h"
+
+
+G_DEFINE_TYPE (GtkScrollbarAccessible, gtk_scrollbar_accessible, GAIL_TYPE_RANGE)
+
+static void
+gtk_scrollbar_accessible_init (GtkScrollbarAccessible *accessible)
+{
+}
+
+static void
+gtk_scrollbar_accessible_initialize (AtkObject *accessible,
+                           gpointer  data)
+{
+  ATK_OBJECT_CLASS (gtk_scrollbar_accessible_parent_class)->initialize (accessible, data);
+
+  accessible->role = ATK_ROLE_SCROLL_BAR;
+}
+
+static gint
+gtk_scrollbar_accessible_get_index_in_parent (AtkObject *accessible)
+{
+  GtkWidget *widget;
+  GtkWidget *parent;
+  GtkWidget *child;
+  GtkScrolledWindow *scrolled_window;
+  gint id;
+
+  widget = gtk_accessible_get_widget (GTK_ACCESSIBLE (accessible));
+  if (widget == NULL)
+    return -1;
+
+  parent = gtk_widget_get_parent (widget);
+  if (!GTK_IS_SCROLLED_WINDOW (parent))
+    return ATK_OBJECT_CLASS (gtk_scrollbar_accessible_parent_class)->get_index_in_parent (accessible);
+
+  scrolled_window = GTK_SCROLLED_WINDOW (parent);
+  id = 0;
+  child = gtk_bin_get_child (GTK_BIN (scrolled_window));
+  if (child)
+    {
+      if (widget == child)
+        return id;
+      id++;
+    }
+
+  child = gtk_scrolled_window_get_hscrollbar (scrolled_window);
+  if (child)
+    {
+      if (widget == child)
+        return id;
+      id++;
+    }
+  child = gtk_scrolled_window_get_vscrollbar (scrolled_window);
+  if (child)
+    {
+      if (widget == child)
+        return id;
+    }
+
+  return -1;
+}
+
+static void
+gtk_scrollbar_accessible_class_init (GtkScrollbarAccessibleClass *klass)
+{
+  AtkObjectClass *class = ATK_OBJECT_CLASS (klass);
+
+  class->initialize = gtk_scrollbar_accessible_initialize;
+  class->get_index_in_parent = gtk_scrollbar_accessible_get_index_in_parent;
+}
diff --git a/gtk/a11y/gtkscrollbaraccessible.h b/gtk/a11y/gtkscrollbaraccessible.h
new file mode 100644 (file)
index 0000000..a593652
--- /dev/null
@@ -0,0 +1,51 @@
+/* GAIL - The GNOME Accessibility Implementation Library
+ * Copyright 2001 Sun Microsystems Inc.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Library General Public
+ * License as published by the Free Software Foundation; either
+ * version 2 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Library General Public License for more details.
+ *
+ * You should have received a copy of the GNU Library General Public
+ * License along with this library; if not, write to the
+ * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
+ * Boston, MA 02111-1307, USA.
+ */
+
+#ifndef __GTK_SCROLLBAR_ACCESSIBLE_H__
+#define __GTK_SCROLLBAR_ACCESSIBLE_H__
+
+#include "gailrange.h"
+
+G_BEGIN_DECLS
+
+#define GTK_TYPE_SCROLLBAR_ACCESSIBLE                     (gtk_scrollbar_accessible_get_type ())
+#define GTK_SCROLLBAR_ACCESSIBLE(obj)                     (G_TYPE_CHECK_INSTANCE_CAST ((obj), GTK_TYPE_SCROLLBAR_ACCESSIBLE, GtkScrollbarAccessible))
+#define GTK_SCROLLBAR_ACCESSIBLE_CLASS(klass)             (G_TYPE_CHECK_CLASS_CAST ((klass), GTK_TYPE_SCROLLBAR_ACCESSIBLE, GtkScrollbarAccessibleClass))
+#define GTK_IS_SCROLLBAR_ACCESSIBLE(obj)                  (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GTK_TYPE_SCROLLBAR_ACCESSIBLE))
+#define GTK_IS_SCROLLBAR_ACCESSIBLE_CLASS(klass)          (G_TYPE_CHECK_CLASS_TYPE ((klass), GTK_TYPE_SCROLLBAR_ACCESSIBLE))
+#define GTK_SCROLLBAR_ACCESSIBLE_GET_CLASS(obj)           (G_TYPE_INSTANCE_GET_CLASS ((obj), GTK_TYPE_SCROLLBAR_ACCESSIBLE, GtkScrollbarAccessibleClass))
+
+typedef struct _GtkScrollbarAccessible      GtkScrollbarAccessible;
+typedef struct _GtkScrollbarAccessibleClass GtkScrollbarAccessibleClass;
+
+struct _GtkScrollbarAccessible
+{
+  GailRange parent;
+};
+
+struct _GtkScrollbarAccessibleClass
+{
+  GailRangeClass parent_class;
+};
+
+GType gtk_scrollbar_accessible_get_type (void);
+
+G_END_DECLS
+
+#endif /* __GTK_SCROLLBAR_ACCESSIBLE_H__ */
index fd79b99eb098e8b8f6cea48001f2f8af5a6bf5e3..01825a98df26cadaaae6d46fb9349df70a5b2780 100644 (file)
@@ -31,6 +31,8 @@
 #include "gtkintl.h"
 #include "gtkprivate.h"
 
+#include "a11y/gtkscrollbaraccessible.h"
+
 
 /**
  * SECTION:gtkscrollbar
@@ -108,6 +110,8 @@ gtk_scrollbar_class_init (GtkScrollbarClass *class)
                                                                  P_("Display a second forward arrow button on the opposite end of the scrollbar"),
                                                                  FALSE,
                                                                  GTK_PARAM_READABLE));
+
+  gtk_widget_class_set_accessible_type (widget_class, GTK_TYPE_SCROLLBAR_ACCESSIBLE);
 }
 
 static void
index 5e2ac9290fb3d95e4058df25d29612c8bdd44311..491b93fba18994d7a4efd99e619b2bfb6488b911 100644 (file)
@@ -396,7 +396,7 @@ Click "Show other applications", for more options, or "Find applications online"
                   <AtkAction>
                   action 0 name: activate
                   action 0 description: activate the cell
-            unnamed-GailScrollbar-8
+            unnamed-GtkScrollbarAccessible-8
               "scroll bar"
               parent: unnamed-GailScrolledWindow-4
               index: 1
@@ -412,7 +412,7 @@ Click "Show other applications", for more options, or "Find applications online"
               maximum value: 0.000000
               current value: 0.000000
               minimum increment: 39.800000
-            unnamed-GailScrollbar-9
+            unnamed-GtkScrollbarAccessible-9
               "scroll bar"
               parent: unnamed-GailScrolledWindow-4
               index: 2